<?php
use yii\helpers\Html;

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>后台管理系统</title>
    <?php echo Html::cssFile('@web/css/bootstrap.min.css'); ?>
    <?php echo Html::cssFile('@web/css/admin.base.css'); ?>
    <?php echo Html::jsFile('@web/javascript/Clock.js'); ?>
    <?php echo Html::jsFile('@web/javascript/jquery.min.js'); ?>
    <?php echo Html::jsFile('@web/javascript/smohan.admin.js'); ?>
    <?php echo Html::jsFile('@web/javascript/bootstrap.min.js'); ?>
</head>
<body>
<div class="container-fluid" style="overflow: hidden;padding-left: 0px;padding-right: 0px;">
    <div class="top topframe">
        <div class="col-sm-7 col-md-5 col-lg-5 hidden-xs">
            <span class="logo"></span>
        </div>
        <div class="col-md-4 col-lg-3 hidden-xs hidden-sm"></div>
        <div class="col-sm-5 col-md-3 col-lg-4">
            <div class="navigation">
                <ul>
                    <li><a href="main.html" target="Main">系统首页</a></li>
                    <li><a href="javascript:void(0)" target="_blank">首页预览</a></li>
                    <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal">修改密码</a></li>
                    <li><a href="<?php echo \yii\helpers\Url::toRoute(['login/logout']);?>" target="_top">退出登录</a></li>
                </ul>
            </div>
            <div class="admin">管理员，您好， <span id=clock></span></div>

            <SCRIPT type=text/javascript>
                var clock = new Clock();
                clock.display(document.getElementById("clock"));
            </SCRIPT>
        </div>
    </div>
    <div class="col-xs-4 col-sm-3 col-md-2" style="padding-left: 0px;">
        <div class="left">
            <div class="div1">
                <div class="div2"><a href="#">文章管理</a></div>
                <div class="div3">
                    <ul>
                        <li><a href="<?php echo \yii\helpers\Url::toRoute(['index/article-list', 'cate_id'=>'1']); ?>">科技</a></li>
                        <li><a href="#">互联</a></li>
                        <li><a href="#">***</a></li>
                    </ul>
                </div>
                <div class="div2"><a href="#">基本管理</a></div>
                <div class="div3">
                    <ul>
                        <li><a href=""> 111</a></li>
                        <li><a href="#"> 111</a></li>
                        <li><a href="#"> 111</a></li>
                        <li><a href="#"> 222</a></li>
                        <li><a href="#"> 333</a></li>
                    </ul>
                </div>
                <div class="div2"><a href="#">基本管理</a></div>
                <div class="div3">
                    <ul>
                        <li><a href="#"> 111</a></li>
                        <li><a href="#"> 222</a></li>
                        <li><a href="#"> 333</a></li>
                    </ul>
                </div>
                <div class="div2"><a href="#">基本管理</a></div>
                <div class="div3">
                    <ul>
                        <li><a href="#"> 111</a></li>
                        <li><a href="#"> 222</a></li>
                        <li><a href="#"> 333</a></li>
                    </ul>
                </div>
                <div class="div2"><a href="#">基本管理</a></div>
                <div class="div3">
                    <ul>
                        <li><a href="#"> 111</a></li>
                        <li><a href="#"> 222</a></li>
                        <li><a href="#"> 333</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="main col-xs-8 col-sm-9 col-md-10">
        <?php echo $content;?>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     style="margin-top: 100px;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">修改密码</h4>
            </div>
            <form class="form-horizontal" method="post"
                  action="<?php echo \yii\helpers\Url::toRoute(['index/changepwd']); ?>">
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="form-group">
                            <label for="oldpwd" class="col-xs-3 col-sm-2 control-label">旧密码</label>

                            <div class="col-xs-9 col-sm-10">
                                <input type="text" class="form-control" name="oldpwd" id="oldpwd" placeholder="请输入旧密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="newpwd" class="col-xs-3 col-sm-2 control-label">新密码</label>

                            <div class="col-xs-9 col-sm-10">
                                <input type="text" class="form-control" name="newpwd" id="newpwd" placeholder="请输入新密码">
                            </div>
                        </div>
                        <input type="hidden" name="_csrf"
                               value="<?php echo \Yii::$app->request->csrfToken;//通过请求组件生成csrfToken;?>">

                        <div id="mes" class="alert alert-danger col-xs-9 col-xs-offset-3 col-sm-10 col-sm-offset-2"
                             style="padding: 8px;margin-bottom: 0px;" role="alert">
                            <button id="closealert" type="button" class="close"><span aria-hidden="true">&times;</span>
                            </button>
                            <div id="message"></div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button id="changepwd" type="button" class="btn btn-primary">确认</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $("#mes").hide();
    $("#closealert").click(function () {
        $("#mes").hide();
    })
    $("#changepwd").click(function () {
        var pwdform = $("#mes").parents('form');
        var formdata = pwdform.serialize();
        var url = pwdform.attr('action');
        $.ajax({
            url: url,
            method: "post",
            dataType: 'json',
            data: formdata,
            error: function () {
                alert("请求失败，请稍后再试");
            },
            success: function (res) {
                if (typeof res == 'object') {
                    if (!res.status) {
                        $("#message").html(res.error);
                        $("#mes").show();
                    } else {
                        var redirect = res.redirect;
                        window.location.href = redirect;
                    }
                } else {
                    alert(res);
                }
            }
        })
    })
</script>
</body>
</html>